package com.yuntu.service;

import com.yuntu.dao.Dev_UserMapper;
import com.yuntu.pojo.Dev_User;
import com.yuntu.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Dev_UserServiceImpl implements Dev_UserService {
    @Autowired
    private Dev_UserMapper dev_userMapper;

    @Override
    public Dev_User login(String devCode, String devPassword) {
        Dev_User user=dev_userMapper.getLoginUser(devCode);
        if (!user.getDevPassword().equals(devPassword)){
            user=null;
        }
        return user;
    }

    @Override
    public int counts() {
        return dev_userMapper.counts();
    }

    @Override
    public void getPageDev_UserList(PageUtil<Dev_User> pageUtil) {
        int count=dev_userMapper.counts();
        System.out.println("========================="+count);
        pageUtil.setCounts(count);
        if (count>0){
            if (pageUtil.getPageindex()>pageUtil.getPagecount()){
                pageUtil.setPageindex(pageUtil.getPagecount());
            }
            pageUtil.setLists(dev_userMapper.getPageDev_UserList(pageUtil));
        }
    }

    @Override
    public boolean addDev_User(Dev_User dev_user) {
        boolean flag=false;
        if (dev_userMapper.addDev_User(dev_user)>0){
            flag=true;
        }
        return flag;
    }

    @Override
    public boolean del_id(int id) {
        boolean flag = false;
        if (dev_userMapper.del_id(id)>0){
            flag = true;
        }
        return flag;
    }

    @Override
    public Dev_User selone(int id) {
        Dev_User peitems = dev_userMapper.selone(id);
        return peitems;
    }

    @Override
    public boolean update(Dev_User dev_user) {
        boolean flag = false;
        if (dev_userMapper.update(dev_user)>0){
            flag = true;
        }
        return flag;
    }

    @Override
    public Dev_User shwo_name(String devName) {
        return dev_userMapper.shwo_name(devName);
    }
}
